import './projectAlbum.scss';

@Inject('$log', '$scope', '$state', 'projectAlbumService')
class projectAlbumController {
  constructor() {
    this.name = this.$state.params.name;
    this.view = {
      subCategories: [],
    };

    this.resource = {
      topCategories: [],
    };

    this.$paginationQuery();
  }

  $paginationQuery() {
    this.projectAlbumService
      .queryCategories()
      .then((res) => {
        // yuxt change
        const rows = res.rows;
        res.rows.forEach((item) => {
          this.resource.topCategories.push(item);
        });
        this.resource.topCategories.forEach((item) => {
          if (item.name === this.$state.params.name) {
            this.view.subCategories = item.subClassifyList;
          }
        });
        // this.resource.topCategories.push({ name: '无人机巡查' });
        // if (rows && rows.length) {
        //   rows[0].selected = true;
        //   this.view.subCategories = rows[0].subClassifyList;
        // }
      });
  }

  chooseTopCategory(topCate) {
    this.resource.topCategories.forEach((top) => {
      top.selected = false;
      if (top === topCate && top.name !== '无人机巡查') {
        top.selected = true;
        this.view.subCategories = top.subClassifyList;
        // this.isShowVideo = false;
      }
      // if (top.name === topCate.name && top.name === '无人机巡查') {
      //   top.selected = true;
      //   this.isShowVideo = true;
      // }
    });
  }
}

export default projectAlbumController;

